<?php
/*DEE_DESC
 $templ=array(
	//Название шаблона в списке ОБЯЗАТЕЛЬНОЕ
	'title'=>'Все видео',
	//Приложения которые будут выводится дополнительно при выборе данного шаблона
	'attaches'=>array(
	));
//DEE_DESC_END*/

$view->css('video_slider');
$youtube = $list_videobaker = $list_nav = $arrows = '';

$view->js_on_load[] = '
			$(document).ready(function(){
				$(".video-slider").sliderkit({
					mousewheel:false,
					shownavitems:4,
					panelbtnshover:false,
					auto:false,
					circular:false,
					navscrollatend:false,
					navpanelautoswitch:false,
					counter:false
				});
			});';

if( isset($_GET['video_cat']) ) {
	$cat_id_clause = 'where video_page_id = '.$_GET['video_cat'];
}
else
	$cat_id_clause = 'where video_page_id = 1';

$conn->query("SELECT `title`, `code`, `site`, `video_page_id` FROM `video` {$cat_id_clause} order by id");

$i = 0;

if( $conn->rowCount() )
{
	while( $video = $conn->fetch() )
	{
		$i++;

		if( $video->site == 'videobaker' )
		{
			$list_videobaker .= '
						<div class="sliderkit-panel">
							<div id="epexportplayer'.$video->code.'"></div><script type="text/javascript" src="http://media.videobaker.ru/export/widget.js"></script>
							<script type="text/javascript">EPexport.widgetHost = "media.videobaker.ru";
							EPexport.Player("epexportplayer'.$video->code.'",{"api":"http%3A%2F%2Fmedia.videobaker.ru%2Fapi%2Fplayer_data","width":640,"height":360,"id":'.$video->code.',"cid":2760},function(player){ /* your code*/ })</script>
						</div>';

			/*  				 	$list_videobaker .= '
									<div class	="sliderkit-panel">
										<iframe frameborder="0" height="360px" width="640px" id="epexport_player" name="epexport_player" scrolling="no" style="width: 640px; height: 360px; " src="http://media.videobaker.ru/index/player?channel_id=2760&record_id='.$video->code.'&width=640&height=360"></iframe>
									</div>'; */
		}
		else
		{
			$youtube .= '
						<div class="sliderkit-panel">
							<iframe width="640" height="360" src="//www.youtube.com/embed/'.$video->code.'?rel=0" frameborder="0" allowfullscreen></iframe>
						</div>';
		}

		$list_nav .= '
					<li>
						<a id="'.$video->code.'" class="a_photo_small" href="#"><img src="/inc/files/video/'.$video->code.'.jpg" alt="video-slider-photo-small" /></a>
						<span>'.$video->title.'</span>
					</li>';
	}

	if( $i > 4 )
		$arrows = '
					<div class="sliderkit-btn sliderkit-nav-btn sliderkit-nav-prev"><a href="#"><span>Предыдущее</span></a></div>
					<div class="sliderkit-btn sliderkit-nav-btn sliderkit-nav-next"><a href="#"><span>Следующее</span></a></div>';

	$html = '
					<div class="sliderkit photosgallery-std video-slider">
						<div class="sliderkit-panels">
							'.$list_videobaker.'
							'.$youtube.'
						</div>
						<div class="sliderkit-nav">
							<div class="sliderkit-nav-clip">
								<ul>
									'.$list_nav.'
								</ul>
							</div>
							'.$arrows.'
						</div>
					</div>';
}
else
	$html = 'По данному запросу видео не найдено';

$view->gText .= $html;
